#ifndef QLIB_COMPONENTGENERAL_H
#define QLIB_COMPONENTGENERAL_H

#include <QFormLayout>

QT_FORWARD_DECLARE_CLASS(QComboBox)
QT_FORWARD_DECLARE_CLASS(QLineEdit)

class LibraryModel;
class QedaComponent;
class QedaLibrary;

class ComponentGeneral : public QFormLayout
{
    Q_OBJECT
public:
    explicit ComponentGeneral(LibraryModel *libModel, QWidget *parent = 0);

    void setLibrary(QedaLibrary *library);
    void setGroup(const QString &group);
    void setReference(const QString &reference);
    
    void dataFrom(QedaComponent *component);
    void dataTo(QedaComponent *component);

    QedaLibrary *library();

    bool valid();

signals:
    void dataChanged();
    
public slots:

private slots:
    void updateRefsAndGroups();
    void addLibrary(QedaLibrary *library);
    void removeLibrary(QedaLibrary *library);
    void groupChanged(const QString &newGroup);
    void referenceChanged(const QString &newReference);
    void changeComponentType(int componentType);
    
private:
    QComboBox           *m_library;
    QLineEdit           *m_name;
    QComboBox           *m_reference;
    QComboBox           *m_group;
    QString              m_currReference;
    QString              m_currGroup;
};

#endif // QLIB_COMPONENTGENERAL_H
